<?
	$title="Add Restaurant"; 
	$pageid="5";
	$accessid="a00";
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	checkAccess("allow_product_category",1);
	$id=$_POST['id'];
	$main_cat=trim($_POST['main_cat']);
	$name_eng=trim($_POST['name_eng']);
	$error=0;
	$clean_url=str_replace(" ","-",$name_eng );
	$is_publish=$_POST['is_publish'];
	$current_main_cat=trim($_POST['current_main_cat']);
	$current_name_eng=trim($_POST['current_name_eng']);
	
	
	if($main_cat!=$current_main_cat || $name_eng!=$current_name_eng)
	{
		$chk=mysql_query("select count(*) as result from os_sub_category where main_category='$main_cat' and name_eng='$name_eng'")or die(mysql_error());
		if(mysql_result($chk,0,"result")>0)
		{
			$error=1;
		}
			
	}	
		
	if($error==1)
	{
		header("Location:subcat_edit.php?id=$id&action=4");
	}
	else
	{
		$update="update os_sub_category set main_category='$main_cat', name_eng='$name_eng',is_publish='$is_publish',clean_url='$clean_url' where id=$id";
	
		$update_q=mysql_query($update)or die(mysql_error());
		header("Location:subcat_management.php?action=3");	
	}
?>
